package de.hsb.ai.learning.filter;

import de.hsb.ai.learning.Replay;
import de.hsb.ai.learning.Transition;
import de.hsb.ai.util.ScotlandJadeGameLogger.Entry;

public class FugitiveEntryFilter {
	
	private static final int FUGITIVE_PLAYER_INDEX = 0;
	
	private boolean acceptAllTransitions = true;
	
	protected final String name;
	
	public FugitiveEntryFilter(String name) {
		this(name, false);
	}
	
	public FugitiveEntryFilter(String name, boolean acceptOnlyChosenTransitions) {
		this.name = name;
		this.acceptAllTransitions  = !acceptOnlyChosenTransitions;
	}
	
	public String getName() {
		return name;
	}
	
	public static boolean isFugitive(int playerIndex) {
		return playerIndex == FUGITIVE_PLAYER_INDEX;
	}
	
	public boolean accepts(Replay replay, Entry entry) {
		return isFugitive(entry.idx);
	}

	public boolean accepts(Transition t) {
		return acceptAllTransitions || t.isChosen();
	}

}
